package netapp.tcp_3;

import java.io.*;
import java.net.InetAddress;
import java.net.Socket;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket(InetAddress.getByName("192.168.12.70"), 8888);
        BufferedOutputStream bow = new BufferedOutputStream((socket.getOutputStream()));
        // 一、客户端向服务器写出文件数据
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("AdvancedCode/source/bg1.jpg"));
        byte[] bytes = new byte[1024 * 10];
        int count;
        while ((count = bis.read(bytes)) != -1){
            bow.write(bytes, 0, count);
            bow.flush();
        }
        // 关闭本地输入流
        bis.close();
        // 禁用socket的输出流
        socket.shutdownOutput();

        // 四、读取服务器的反馈数据
        BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        String s = br.readLine();
        System.out.println(s);
        // 关闭客户端
        socket.close();

    }
}
